<html>

<head>
    <!-- 中文支持 -->
    <meta charset="utf-8">
</head>

<body>
    <h2>sciter中使用vue3</h2>



    <div id="counter">
        Counter: {{ counter }}
    </div>

    <div id="bind-attribute">
        <span v-bind:title="message">
            鼠标悬停几秒钟查看此处动态绑定的提示信息！
        </span>
    </div>


    <div id="event-handling">
        <p>{{ message }}</p>
        <button v-on:click="reverseMessage">反转 Message</button>
    </div>


    <div id="two-way-binding">
        <p>{{ message }}</p>
        <input v-model="message" />
    </div>


    <div id="conditional-rendering">
        <span v-if="seen">现在你看到我了</span>
    </div>

    <div id="list-rendering">
        <ol>
            <li v-for="todo in todos">
                {{ todo.text }}
            </li>
        </ol>
    </div>


    <div id="todo-list-app">
        <ol>
            <todo-item v-for="item in groceryList" v-bind:todo="item" v-bind:key="item.id"></todo-item>
        </ol>
    </div>

    <div id="computed-basics">
        <p>Has published books:</p>
        <span>{{ publishedBooksMessage }}</span>
    </div>



</body>
<!-- 兼容性存在问题 稍微修改下 -->
<!-- 
需要修改3个地方
1. 注销document.createEvent 这个是兼容edge浏览器特例处理
2. console.info 在sciter没有 需要特别声明
3. 去掉SVGElement的判定 


 -->
<script src="./vue3.js"></script>

<script>
    const Counter = {
        data() {
            return {
                counter: 0
            }
        }
    }
    Vue.createApp(Counter).mount('#counter')


    const AttributeBinding = {
        data() {
            return {
                message: 'You loaded this page on ' + new Date().toLocaleString()
            }
        }
    }

    Vue.createApp(AttributeBinding).mount('#bind-attribute')


    const EventHandling = {
        data() {
            return {
                message: 'Hello Vue.js!'
            }
        },
        methods: {
            reverseMessage() {
                this.message = this.message
                    .split('')
                    .reverse()
                    .join('')
            }
        }
    }

    Vue.createApp(EventHandling).mount('#event-handling')


    const TwoWayBinding = {
        data() {
            return {
                message: 'Hello Vue!'
            }
        }
    }

    Vue.createApp(TwoWayBinding).mount('#two-way-binding')


    const ConditionalRendering = {
        data() {
            return {
                seen: true
            }
        }
    }

    Vue.createApp(ConditionalRendering).mount('#conditional-rendering')


    const ListRendering = {
        data() {
            return {
                todos: [
                    { text: 'Learn JavaScript' },
                    { text: 'Learn Vue' },
                    { text: 'Build something awesome' }
                ]
            }
        }
    }

    Vue.createApp(ListRendering).mount('#list-rendering')


    const TodoList = {
        data() {
            return {
                groceryList: [
                    { id: 0, text: 'Vegetables' },
                    { id: 1, text: 'Cheese' },
                    { id: 2, text: 'Whatever else humans are supposed to eat' }
                ]
            }
        }
    }

    const app = Vue.createApp(TodoList)

    app.component('todo-item', {
        props: ['todo'],
        template: `<li>{{ todo.text }}</li>`
    })

    app.mount('#todo-list-app')


    Vue.createApp({
        data() {
            return {
                author: {
                    name: 'John Doe',
                    books: [
                        'Vue 2 - Advanced Guide',
                        'Vue 3 - Basic Guide',
                        'Vue 4 - The Mystery'
                    ]
                }
            }
        },
        computed: {
            // 计算属性的 getter
            publishedBooksMessage() {
                // `this` 指向 vm 实例
                return this.author.books.length > 0 ? 'Yes' : 'No'
            }
        }
    }).mount('#computed-basics')


    Vue.createApp({
        data() {
            return {
                counter: 0
            }
        },
        methods: {
            addCounter() {
                console.log("ccc", this.counter);
                this.counter = this.counter + 1;
            }
        }
    }).mount('#basic-event')

</script>

</html>